import Vue from 'vue'
import './cube-ui'
import App from './App.vue'
import router from './router'
import store from './store'
import common from './components/index.js'
import http from './util/axios'
import 'amfe-flexible'

import '@/util/RongIMLib-2.4.0.min.js'
import '@/util/RongEmoji-2.2.7.min.js'
import RongCloud from  '@/util/RongCloud.js'
import IndexedDB from  '@/util/IndexedDB.js'

let Rong =  null
let DB =  new IndexedDB('chatTable',1);
window.DB = DB;
DB.upgradeneeded('huahui_chat')

console.log(process.env.VUE_APP_DOMAIN_CONFIG)

Vue.use(common)
Vue.use(http)
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App),
  created(){
    if(window.location.href.indexOf('down') < 0 && window.location.href.indexOf('login') < 0){
      this.getMyAccount()
    }
  },
  mounted(){
    
  },
  methods:{
    getMyAccount(){
      this.$http.get('/Message/getMyAccount').then(res => {
        console.log(res)
        if(res.code == 200){
          this.$store.commit('setRong',res.data)
          Rong = new RongCloud()
          Vue.prototype.$Rong = Rong;
          Vue.prototype.$DB = DB;
        }
      })
    }
  }
}).$mount('#app')
